//
//  ZLAlert+ZLButton.h
//  ZLAlert-OC
//
//  Created by 科大 on 2024/1/2.
//

#import "ZLAlert.h"
#import <Masonry/Masonry.h>

NS_ASSUME_NONNULL_BEGIN
/// 单按钮
@interface ZLAlertButton : UIButton
/// 回调
@property (nonatomic, copy) ZlAlertAction action;
/// 点击是否消失
@property (nonatomic, assign) BOOL dismiss;

/// 初始化
/// - Parameters:
///   - title: 标题
///   - dismiss: 是否点击关闭弹窗
///   - config: 配置项
///   - action: 回调
+ (ZLAlertButton *)zl_buttonWithTitle:(NSString *)title
                              dismiss:(BOOL)dismiss
                               config:(ZLAlertItemConfig *)config
                               action:(nullable ZlAlertAction)action;

@end

/// 协议
@protocol ZLAlertDoubleButtonDelegate;
/// 双按钮
@interface ZLAlertDoubleButton : UIView
/// 左侧按钮
@property (nonatomic, strong, readonly) ZLAlertButton *leftButton;
/// 右侧按钮
@property (nonatomic, strong, readonly) ZLAlertButton *rightButton;
/// 中间分割线
@property (nonatomic, strong, readonly, nullable) UIView *centerLine;
/// 代理
@property (nonatomic, weak) id<ZLAlertDoubleButtonDelegate> delegate;

/// 初始化
/// - Parameters:
///   - leftTitle: 左侧标题
///   - leftDismiss: 点击是否关闭弹窗
///   - leftConfig: 左侧按钮配置
///   - leftAction: 左侧点击回调
///   - showCenterLine: 是否显示中间分割线
///   - lineConfig: 线配置
///   - rightTitle: 右侧标题
///   - rightDismiss: 右侧点击是否关闭弹窗
///   - rightConfig: 右侧按钮配置
///   - rightAction: 右侧点击回调
- (instancetype)initWithLeftTitle:(NSString *)leftTitle
                      leftDismiss:(BOOL)leftDismiss
                       leftConfig:(ZLAlertItemConfig *)leftConfig
                       leftAction:(nullable ZlAlertAction)leftAction
                   showCenterLine:(BOOL)showCenterLine
                       lineConfig:(ZLAlertItemConfig *)lineConfig
                       rightTitle:(NSString *)rightTitle
                     rightDismiss:(BOOL)rightDismiss
                      rightConfig:(ZLAlertItemConfig *)rightConfig
                      rightAction:(nullable ZlAlertAction)rightAction;
@end

/// 协议
@protocol ZLAlertDoubleButtonDelegate <NSObject>

/// 点击左侧
/// - Parameter button: 左侧按钮
- (void)alertDoubleButtonTapLeft:(ZLAlertButton *)button;
/// 点击右侧
/// - Parameter button: 右侧按钮
- (void)alertDoubleButtonTapRight:(ZLAlertButton *)button;

@end

@interface ZLAlert (ZLButton)<ZLAlertDoubleButtonDelegate>


/// 增加双按钮使用默认配置
/// - Parameters:
///   - leftTitle: 左侧标题
///   - leftAction: 点击回调
///   - showCenterLine: 是否显示中间线
///   - rightTitle: 右侧标题
///   - rightAction: 右侧回调
- (ZLAlert *)addDoubleAction:(NSString *)leftTitle
                  leftAction:(nullable ZlAlertAction)leftAction
              showCenterLine:(BOOL)showCenterLine
                  rightTitle:(NSString *)rightTitle
                 rightAction:(nullable ZlAlertAction)rightAction;

/// 增加双按钮自定义配置
/// - Parameters:
///   - leftTitle: 左侧标题
///   - leftDismiss: 点击是否关闭弹窗
///   - leftConfig: 左侧按钮配置
///   - leftAction: 左侧点击回调
///   - showCenterLine: 是否显示中间分割线
///   - lineConfig: 线配置
///   - rightTitle: 右侧标题
///   - rightDismiss: 右侧点击是否关闭弹窗
///   - rightConfig: 右侧按钮配置
///   - rightAction: 右侧点击回调
- (ZLAlert *)addDoubleAction:(NSString *)leftTitle
                 leftDismiss:(BOOL)leftDismiss
                  leftConfig:(ZLAlertItemConfig *)leftConfig
                  leftAction:(nullable ZlAlertAction)leftAction
              showCenterLine:(BOOL)showCenterLine
                  lineConfig:(ZLAlertItemConfig *)lineConfig
                  rightTitle:(NSString *)rightTitle
                rightDismiss:(BOOL)rightDismiss
                 rightConfig:(ZLAlertItemConfig *)rightConfig
                 rightAction:(nullable ZlAlertAction)rightAction;

/// 增加单按钮使用默认配置
/// - Parameters:
///   - title: 标题
///   - action: 回调
- (ZLAlert *)addButton:(NSString *)title
                action:(nullable ZlAlertAction)action;

/// 增加单按钮自定义配置
/// - Parameters:
///   - title: 标题
///   - dismiss: 点击是否关闭弹窗
///   - config: 配置
///   - action: 回调
- (ZLAlert *)addButton:(NSString *)title
               dismiss:(BOOL)dismiss
                config:(ZLAlertItemConfig *)config
                action:(nullable ZlAlertAction)action;

@end

NS_ASSUME_NONNULL_END
